package santeclair.referentiel.optique.model;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import santeclair.lunar.framework.annotation.Code;
import santeclair.lunar.framework.annotation.HashCodeEquals;
import santeclair.lunar.framework.annotation.ToString;
import santeclair.lunar.framework.util.EqualsUtils;
import santeclair.lunar.framework.util.HashCodeUtils;
import santeclair.lunar.framework.util.ToStringUtils;
import santeclair.referentiel.optique.config.Constant;

@Entity
@Table(name = "tr_traitement_grille", catalog = Constant.SCHEMA_NAME, uniqueConstraints = @UniqueConstraint(columnNames = "code_traitement_grille"))
public class TraitementGrille implements java.io.Serializable {

    private static final long serialVersionUID = 8045613598435945137L;

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "identifiant_traitement_grille", unique = true, nullable = false)
    @HashCodeEquals
    @ToString
    private Integer identifiantTraitementGrille;

    @Code
    @Column(name = "code_traitement_grille", unique = true, nullable = false, length = 10)
    @HashCodeEquals
    @ToString
    @Enumerated(EnumType.STRING)
    private String codeTraitementGrille;

    @Column(name = "libelle_traitement_grille", nullable = false)
    @HashCodeEquals
    @ToString
    private String libelleTraitementGrille;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "identifiant_traitement_verre", nullable = false)
    @HashCodeEquals
    @ToString
    private TraitementVerre traitementVerre;

    @Column(name = "identifiant_traitement_verre", insertable = false, updatable = false)
    @HashCodeEquals
    @ToString
    private Integer identifiantTraitementVerre;

    public TraitementGrille() {
    }

    public String getCode() {
        return this.codeTraitementGrille;
    }

    public void setCode(String codeTraitementGrille) {
        this.codeTraitementGrille = codeTraitementGrille;
    }

    public String getLibelle() {
        return this.libelleTraitementGrille;
    }

    public void setLibelle(String libelleTraitementGrille) {
        this.libelleTraitementGrille = libelleTraitementGrille;
    }

    public Integer getIdentifiantTraitementGrille() {
        return identifiantTraitementGrille;
    }

    public void setIdentifiantTraitementGrille(Integer identifiantTraitementGrille) {
        this.identifiantTraitementGrille = identifiantTraitementGrille;
    }

    public String getCodeTraitementGrille() {
        return codeTraitementGrille;
    }

    public void setCodeTraitementGrille(String codeTraitementGrille) {
        this.codeTraitementGrille = codeTraitementGrille;
    }

    public String getLibelleTraitementGrille() {
        return libelleTraitementGrille;
    }

    public void setLibelleTraitementGrille(String libelleTraitementGrille) {
        this.libelleTraitementGrille = libelleTraitementGrille;
    }

    public TraitementVerre getTraitementVerre() {
        return traitementVerre;
    }

    public void setTraitementVerre(TraitementVerre traitementVerre) {
        this.traitementVerre = traitementVerre;
    }

    /**
     * @return the identifiantTraitementVerre
     */
    public Integer getIdentifiantTraitementVerre() {
        return identifiantTraitementVerre;
    }

    @Override
    public String toString() {
        return ToStringUtils.toString(this);
    }

    @Override
    public int hashCode() {
        return HashCodeUtils.hashCode(this);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsUtils.isEqual(this, obj);
    }
}
